<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 19666
  Date: 2022/8/2
  Time: 15:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>四大名著</title>
</head>
<body>
    <h1>PageContext作用域示例</h1>
    <%
        // 这里是pageContext定义的 "books"
        List<String> books = (List<String>) pageContext.getAttribute("books");
        out.println("【PageContext作用域示例】===>" + books);
    %>

    <h1>Request作用域示例</h1>
    <%
        // request这里是定义的 "books"
         books = (List<String>) request.getAttribute("books");
        out.println("【Request作用域示例】===>" + books);
    %>

    <h1>Session作用域示例</h1>
    <%
        // session这里是定义的 "books"
        books = (List<String>) session.getAttribute("books");
        out.println("【Session作用域示例】===>" + books + " SessionId->" + session.getId());
        session.removeAttribute("books"); // 调用session的移除方法
    %>

    <h1>Application作用域示例</h1>
    <%
        // application这里是定义的 "books"
        books = (List<String>) application.getAttribute("books");
        out.println("【Application作用域示例】===>" + books);
    %>

</body>
</html>
